#ifndef _FIB_HEAP_
#define _FIB_HEAP_

#include<stdlib.h>

struct Entry {
  int elem;
  struct Entry *child;
  struct Entry *parent;
  struct Entry *next, *prev;
  char marked;
  int degree;
  double priority;
};

typedef struct Entry Entry;

typedef struct {
  int size;
  Entry *min;
} FibHeap;

Entry *newEntry(double elem, double priority);
FibHeap *newFibHeap();
Entry *mergeLists(Entry *one, Entry *two);
Entry *enqueue(FibHeap *fh, double value, double priority);
Entry *min(FibHeap *fh);
int isEmpty(FibHeap *fh);
int size(FibHeap *fh);
FibHeap *merge(FibHeap *one, FibHeap *two);
Entry *dequeueMin(FibHeap *fh);
void cutNode(FibHeap *fh, Entry *e);
void decreaseKeyUnchecked(FibHeap *fh, Entry *e, double priority);
void decreaseKey(FibHeap *fh, Entry *e, double newPriority);
void delete(FibHeap *fh, Entry *e);

#endif
